package com.diet.system.service.impl;

import com.diet.common.utils.DateUtils;
import com.diet.system.domain.Ingredient;
import com.diet.system.mapper.IngredientMapper;
import com.diet.system.service.IIngredientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 食材Service业务层处理
 */
@Service
public class IngredientServiceImpl implements IIngredientService 
{
    @Autowired
    private IngredientMapper ingredientMapper;

    /**
     * 查询食材
     * 
     * @param ingredientId 食材主键
     * @return 食材
     */
    @Override
    public Ingredient selectIngredientByIngredientId(Long ingredientId)
    {
        return ingredientMapper.selectIngredientByIngredientId(ingredientId);
    }

    /**
     * 查询食材列表
     * 
     * @param ingredient 食材
     * @return 食材
     */
    @Override
    public List<Ingredient> selectIngredientList(Ingredient ingredient)
    {
        return ingredientMapper.selectIngredientList(ingredient);
    }

    /**
     * 新增食材
     * 
     * @param ingredient 食材
     * @return 结果
     */
    @Override
    public int insertIngredient(Ingredient ingredient)
    {
        ingredient.setCreateTime(DateUtils.getNowDate());
        return ingredientMapper.insertIngredient(ingredient);
    }

    /**
     * 修改食材
     * 
     * @param ingredient 食材
     * @return 结果
     */
    @Override
    public int updateIngredient(Ingredient ingredient)
    {
        ingredient.setUpdateTime(DateUtils.getNowDate());
        return ingredientMapper.updateIngredient(ingredient);
    }

    /**
     * 批量删除食材
     * 
     * @param ingredientIds 需要删除的食材主键
     * @return 结果
     */
    @Override
    public int deleteIngredientByIngredientIds(Long[] ingredientIds)
    {
        return ingredientMapper.deleteIngredientByIngredientIds(ingredientIds);
    }

    /**
     * 删除食材信息
     * 
     * @param ingredientId 食材主键
     * @return 结果
     */
    @Override
    public int deleteIngredientByIngredientId(Long ingredientId)
    {
        return ingredientMapper.deleteIngredientByIngredientId(ingredientId);
    }
}